<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<script type="text/javascript" charset="utf-8"
	src="<?php echo Yii::app()->baseUrl?>/kindeditor/kindeditor-min.js"></script>
<script type="text/javascript" charset="utf-8"
	src="<?php echo Yii::app()->baseUrl?>/layer/layer.js"></script>
<link rel="stylesheet"
	href="http://kindeditor.net/ke4/themes/default/default.css"
	type="text/css" />
<script type="text/javascript" charset="utf-8"
	src="<?php echo Yii::app()->baseUrl?>/layer/modernizr.custom.js"></script>
<script type="text/javascript"
	src="<?php echo Yii::app()->baseUrl?>/kindeditor/h5Client.js"></script>
<link rel="stylesheet"
	href="<?php echo Yii::app()->baseUrl?>/css/default.css" type="text/css" />
<link rel="stylesheet"
	href="<?php echo Yii::app()->baseUrl?>/css/component.css"
	type="text/css" />
<style>
.am-input-group-primary .am-input-group-btn>.am-btn,
	.am-input-group-primary .am-input-group-label, .am-input-group-primary.am-input-group .am-form-field
	{
	border-color: #CD853F;
}

.search_btn {
	border-radius: 5px;
	-webkit-border-radius: 5px;
	-moz-border-radius: 5px;
	border-bottom-right-radius: 0px;
	border-top-right-radius: 0px;
}

.am-tabs-default .am-tabs-nav>.am-active a {
	background-color: #CD853F;
	color: #fff;
	/*           border-radius:5px;
           -webkit-border-radius:5px;
           -moz-border-radius:5px;
           border-bottom-right-radius: 0px;
           border-top-right-radius: 0px;*/
}

.am-tabs-default .am-tabs-nav a {
	background-color: #ffd5df;
	color: #222;
	line-height: 42px;
	/*            border-radius:5px;
            -webkit-border-radius:5px;
            -moz-border-radius:5px;
            border-bottom-left-radius: 0px;
            border-top-left-radius: 0px;*/
}

.middle-demo-1 {
	height: 3em;
	line-height: 3em;
	overflow: hidden;
}

.ul_li_img {
	width: 10%;
	margin-left: 1em;
}

.ul_li_span {
	font-size: 20px;
	margin-left: 1em;
}

.i_ul_rel {
	display: block;
	padding: 0 0 0 14px;
	left: -10px;
	position: relative;
	list-style-type: none;
}

.i_li_left {
	padding-left: 5px;
	width: 50%;
	position: relative;
	margin-bottom: 6px;
	box-sizing: border-box;
	-moz-box-sizing: border-box;
	-webkit-box-sizing: border-box;
	float: left;
}

.i_txt {
	font-size: 16px;
	color: #323232;
	height: 20px;
	line-height: 18px;
	/*margin: 10px 0 6px;*/
	overflow: hidden;
	text-overflow: ellipsis;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	/*padding: 0 6px;*/
	word-break: break-all;
}

.am-input-group-primary .am-input-group-btn>.am-btn,
	.am-input-group-primary .am-input-group-label, .am-input-group-primary.am-input-group .am-form-field
	{
	border-color: #CD853F;
}

.am-tabs-default .am-tabs-nav a {
	background-color: #ffd5df;
	color: #222;
	line-height: 42px;
	border-radius: 5px;
	-webkit-border-radius: 5px;
	-moz-border-radius: 5px;
}

.am-tabs-bd {
	position: relative;
	overflow: hidden;
	border: 0px solid #ddd;
	border-top: none;
	z-index: 100;
	-webkit-transition: height .3s;
	transition: height .3s;
}
</style>
<script>
            //afterValidate     
            function loadding(){
                layer.load(0, {shade: [0.1,"#070707"] });
                return false;
            } 
            
            function close(){
            layer.closeAll(); //疯狂模式，关闭所有层
            } 
            function selectMsg(){
                if($("#select_text").val()!=""){
                    loadding();
                    var text=$("#select_text").val();
                    var type=2;
                    //判断是否为数字
                    if(/^\d+$/.test(text)){
                        type=1;
                    }
                    var url='<?php echo Yii::app()->baseUrl?>/index.php/default/selectMsg';
                    jQuery.ajax({'type':'POST','url':url,'success':function(data){                                                  
                                                   var d_t=eval("("+data+")");
                                                       var temp="";
                                                       temp+='<div data-tab-panel-1 class="am-tab-panel " style="padding-left: 0px; padding-right: 0px;">'+
                                                       '<ul class="grid effect-1"  id="hot_ul">';
                                                        for(var i=0;i<d_t.length;i++){
                                                             temp+='<li class="i_li_left">'+
                                                                        
                                                                            '<div style="border:solid 1px #cdccc9; background-color:#F0F8FF; ">'+
                                                                            '<a href="<?php echo Yii::app()->baseUrl?>/index.php/default/children_msg/'+d_t[i].id+'">'+
                                                                              '<div style=" text-align: center; margin: 10px 10px; background-color: #EEEEEE;">'+
                                                                                '<img src="'+d_t[i].head_image+'" style="min-height: 150px; width: 100%; padding:10px 10px 0px 10px;">'+
                                                                                '<span class="i_txt">'+d_t[i].id+'号：'+d_t[i].username+'</span>'+
                                                                              '</div>'+
                                                                              '</a>'+
                                                                              '<div style=" text-align: center; margin-bottom: 1em; ">'+
                                                                                '<button onclick="vote('+d_t[i].id+')" type="button" class="am-btn am-btn-danger" style="font-size: 13px;border-radius:10px;-webkit-border-radius:5px;-moz-border-radius:5px">投票</button>'+
                                                                                '<span style="color: #CD853F; margin-left: 0.5em; vertical-align:middle;">'+d_t[i].number+'票</span>'
                                                                              '</div>'+
                                                                            '</div>'+
                                                                        
                                                                    '</li>';

                                                        }
                                                        $("#postion").html(temp); 
                                                        new AnimOnScroll( document.getElementById( 'hot_ul' ), {
                                                                minDuration : 0.4,
                                                                maxDuration : 0.7,
                                                                viewportFactor : 0.2
                                                        } );                                                        
                                                       // alert(temp);
                                                        close(); 
                                                        
                                                    },'cache':false,'data':"username="+$("#select_text").val()+"&type="+type});
                                                    return false;                    
                }
            }
        function vote(id){

            if(isWeiXin()==true)
            {
        	alert('投票需通过"智慧烟台"app,登入成功后即可参加投票！');
        	window.location.href="http://www.zhyantai.com/folder53/index.html";
        	return false;  
            }
        else
        {
			hgClient.getUserInfo(function(response) {
        		
                var userInfo = response && (response.userInfo || response)
     					|| '';
     			userInfo = jQuery.parseJSON(JSON.stringify(userInfo));
     			var userTokenKey = userInfo.userTokenKey;
     			var app_user_id = userInfo.userid;
     			
     			if (userTokenKey == null ||userTokenKey.length == 0)
     			{
     				hgClient.goLogin();
     				return false;
     			}
     			else
     			{
    				 loadding();
    				 var _json = jQuery.param({
      					"id" : id,
      					"app_user_id" : app_user_id,
      					"openid" : device_token								
      				});
    	 	            var url='<?php echo Yii::app()->baseUrl?>/index.php/default/set_vote';
    	 	         
    	 	            jQuery.ajax(
    	    	 	            {
   	    	 	            	 'url':url,
    	        	 	         'type':'POST',
     	        	 	         'async' : false,
       	        	 	       'data':_json,
       	        	 	       'dataType':'json',
           	        	 	   'cache':false,
        	 	            'complete':function(data){
     	 	              		 var dic = data.responseText;
    	 	                    close();
    	 	                    if(dic=="每天只能投一票，谢谢。"){
    	 	                        layer.alert(dic, {icon: 7},function(index){  
    	 	                        location.reload();
    	 	                        }); 
    	 	                    }else{
    	 	                        layer.alert(dic, {icon: 6},function(index){  
    	 	                        location.reload();
    	 	                        });                         
    	 	                    }
    	 	                }
     	 	            });
    	 	            return false;        
     			}
                     	
                 	});
        }

        }
        function isWeiXin(){
            var ua = window.navigator.userAgent.toLowerCase();
            if(ua.match(/MicroMessenger/i) == 'micromessenger' || ua.match(/QQ/i) == "qq"){
                return true;
            }else{
                return false;
            } 
        }  
        var device_token='';
        $(function () {
        	hgClient.getSystemInfo(function( response ){//获取设备信息
				var systemInfo = response.deviceInfo || response;
				systemInfo = jQuery.parseJSON(JSON.stringify(systemInfo));
	     		device_token = systemInfo.device_token;
			});
        });
        </script>
</head>
<body>
	<div>
		<div class="am-g" style="margin-top: 1em;">
			<div class="am-u-lg-6">
				<div class="am-input-group am-input-group-primary">
					<span class="am-input-group-btn">
						<button onclick="selectMsg()" class="am-btn am-btn-primary"
							style="background-color: #CD853F; border-radius: 5px; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-bottom-right-radius: 0px; border-top-right-radius: 0px;"
							type="button">
							<span class="am-icon-search"></span>
						</button>
					</span>
                    <?php
                    if ($index > 0) {
                        ?>
                    <input id="select_text"
						value="<?php echo $username; ?>" type="text"
						placeholder="输入编号或者名称" class="am-form-field"
						style="padding-right: 5px; border-radius: 5px; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-bottom-left-radius: 0px; border-top-left-radius: 0px;">
                    <?php }else{?>
                    <input id="select_text" type="text"
						placeholder="输入编号或者名称" class="am-form-field"
						style="padding-right: 5px; border-radius: 5px; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-bottom-left-radius: 0px; border-top-left-radius: 0px;">                        
                    <?php } ?> 
                </div>
			</div>
		</div>
		<div id="postion">  
             <?php
            if ($index > 0) {
                ?>
                <div data-tab-panel-1 class="am-tab-panel "
				style="padding-left: 0px; padding-right: 0px;">
				<ul class="grid effect-1" id="hot_ul">        
            <?php
                foreach ($model as $value) {
                    if($value->is_check=1){
                    ?>
           <li class="i_li_left">
						<div style="border: solid 1px #cdccc9; background-color: #F0F8FF;">
							<a
								href="<?php echo Yii::app()->baseUrl?>/index.php/default/children_msg/<?php echo CHtml::encode($value->id);?>">
								<div
									style="text-align: center; margin: 10px 10px; background-color: #EEEEEE;">
									<img src="<?php echo $value->head_image;?>"
										style="min-height: 150px; width: 100%; padding: 10px 10px 0px 10px;">
									<span class="i_txt"><?php echo CHtml::encode($value->id);?>号：<?php echo CHtml::encode($value->username);?></span>
								</div>
							</a>
							<div style="text-align: center; margin-bottom: 1em;">
								<button onclick="vote(<?php echo $value->id ?>)" type="button"
									class="am-btn am-btn-danger"
									style="font-size: 13px; border-radius: 10px; -webkit-border-radius: 5px; -moz-border-radius: 5px">投票</button>
								<span
									style="color: #CD853F; margin-left: 0.5em; vertical-align: middle;"><?php echo CHtml::encode($value->number);?>票</span>
							</div>
						</div>
					</li>
           <?php
                
}
                ?>
            </ul>
			</div>                
            <?php  } } ?>      
            </div>
	</div>
	<script
		src="<?php echo Yii::app()->baseUrl?>/layer/masonry.pkgd.min.js"></script>
	<script src="<?php echo Yii::app()->baseUrl?>/layer/imagesloaded.js"></script>
	<script src="<?php echo Yii::app()->baseUrl?>/layer/classie.js"></script>
	<script src="<?php echo Yii::app()->baseUrl?>/layer/AnimOnScroll.js"></script>
	<script type="text/javascript">
new AnimOnScroll( document.getElementById( 'hot_ul' ), {
	minDuration : 0.4,
	maxDuration : 0.7,
	viewportFactor : 0.2
} );
</script>
</body>
</html>
